



<!doctype html>
<html lang="en" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      <meta http-equiv="x-ua-compatible" content="ie=edge">
      
        <meta name="description" content="Here you can find all documents about QTrobot.">
      
      
        <link rel="canonical" href="https://luxai-qtrobot.github.io/examples/qt_motors_moveit/">
      
      
        <meta name="author" content="QTrobot">
      
      
        <meta name="lang:clipboard.copy" content="Copy to clipboard">
      
        <meta name="lang:clipboard.copied" content="Copied to clipboard">
      
        <meta name="lang:search.language" content="en">
      
        <meta name="lang:search.pipeline.stopwords" content="True">
      
        <meta name="lang:search.pipeline.trimmer" content="True">
      
        <meta name="lang:search.result.none" content="No matching documents">
      
        <meta name="lang:search.result.one" content="1 matching document">
      
        <meta name="lang:search.result.other" content="# matching documents">
      
        <meta name="lang:search.tokenizer" content="[\s\-]+">
      
      <link rel="shortcut icon" href="../../img/luxai-favicon.ico">
      <meta name="generator" content="mkdocs-1.1, mkdocs-material-4.6.3">
    
    
      
        <title>Controlling QTrobot arms using MoveIt - QTrobot Documentation</title>
      
    
    
      <link rel="stylesheet" href="../../assets/stylesheets/application.adb8469c.css">
      
        <link rel="stylesheet" href="../../assets/stylesheets/application-palette.a8b3c06d.css">
      
      
        
        
        <meta name="theme-color" content="#3f51b5">
      
    
    
      <script src="../../assets/javascripts/modernizr.86422ebf.js"></script>
    
    
      
        <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback">
        <style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
      
    
    <link rel="stylesheet" href="../../assets/fonts/material-icons.css">
    
    
      <link rel="stylesheet" href="../../stylesheets/extra.css">
    
    
      
    
    
  </head>
  
    
    
    <body dir="ltr" data-md-color-primary="indigo" data-md-color-accent="indigo">
  
    <svg class="md-svg">
      <defs>
        
        
      </defs>
    </svg>
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
    
      <a href="#controlling-qtrobot-arms-using-moveit" tabindex="0" class="md-skip">
        Skip to content
      </a>
    
    
      <header class="md-header" data-md-component="header">
  <nav class="md-header-nav md-grid">
    <div class="md-flex">
      <div class="md-flex__cell md-flex__cell--shrink">
        <a href="https://luxai-qtrobot.github.io/" title="QTrobot Documentation" aria-label="QTrobot Documentation" class="md-header-nav__button md-logo">
          
            <img alt="logo" src="../../img/logo_luxai_white.png" width="24" height="24">
          
        </a>
      </div>
      <div class="md-flex__cell md-flex__cell--shrink">
        <label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
      </div>
      <div class="md-flex__cell md-flex__cell--stretch">
        <div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
          
            <span class="md-header-nav__topic">
              QTrobot Documentation
            </span>
            <span class="md-header-nav__topic">
              
                Controlling QTrobot arms using MoveIt
              
            </span>
          
        </div>
      </div>
      <div class="md-flex__cell md-flex__cell--shrink">
        
          <label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
          
<div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" aria-label="search" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active">
      <label class="md-icon md-search__icon" for="__search"></label>
      <button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
        &#xE5CD;
      </button>
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="result">
          <div class="md-search-result__meta">
            Type to start searching
          </div>
          <ol class="md-search-result__list"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
        
      </div>
      
    </div>
  </nav>
</header>
    
    <div class="md-container">
      
        
      
      
      <main class="md-main" role="main">
        <div class="md-main__inner md-grid" data-md-component="container">
          
            
              <div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    <nav class="md-nav md-nav--primary" data-md-level="0">
  <label class="md-nav__title md-nav__title--site" for="__drawer">
    <a href="https://luxai-qtrobot.github.io/" title="QTrobot Documentation" class="md-nav__button md-logo">
      
        <img alt="logo" src="../../img/logo_luxai_white.png" width="48" height="48">
      
    </a>
    QTrobot Documentation
  </label>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
      


  <li class="md-nav__item">
    <a href="../.." title="Home" class="md-nav__link">
      Home
    </a>
  </li>

    
      
      
      


  <li class="md-nav__item">
    <a href="../../user-manual/" title="Quick Start" class="md-nav__link">
      Quick Start
    </a>
  </li>

    
      
      
      


  <li class="md-nav__item">
    <a href="../../api/" title="API Reference" class="md-nav__link">
      API Reference
    </a>
  </li>

    
      
      
      


  <li class="md-nav__item md-nav__item--nested">
    
      <input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4">
    
    <label class="md-nav__link" for="nav-4">
      FAQ
    </label>
    <nav class="md-nav" data-md-component="collapsible" data-md-level="1">
      <label class="md-nav__title" for="nav-4">
        FAQ
      </label>
      <ul class="md-nav__list" data-md-scrollfix>
        
        
          
          
          


  <li class="md-nav__item">
    <a href="../../FAQ/Audio/" title="Audio" class="md-nav__link">
      Audio
    </a>
  </li>

        
          
          
          


  <li class="md-nav__item">
    <a href="../../FAQ/Autostart/" title="Autostart" class="md-nav__link">
      Autostart
    </a>
  </li>

        
          
          
          


  <li class="md-nav__item">
    <a href="../../FAQ/Motors/" title="Motors" class="md-nav__link">
      Motors
    </a>
  </li>

        
          
          
          


  <li class="md-nav__item">
    <a href="../../FAQ/Network/" title="Network" class="md-nav__link">
      Network
    </a>
  </li>

        
          
          
          


  <li class="md-nav__item">
    <a href="../../FAQ/Miscellaneous/" title="Miscellaneous" class="md-nav__link">
      Miscellaneous
    </a>
  </li>

        
      </ul>
    </nav>
  </li>

    
      
      
      


  <li class="md-nav__item">
    <a href="../../demos/" title="Demos" class="md-nav__link">
      Demos
    </a>
  </li>

    
      
      
      


  <li class="md-nav__item">
    <a href="../" title="Examples" class="md-nav__link">
      Examples
    </a>
  </li>

    
      
      
      


  <li class="md-nav__item">
    <a href="../../author-note/" title="Author's Note" class="md-nav__link">
      Author's Note
    </a>
  </li>

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              <div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    
<nav class="md-nav md-nav--secondary">
  
  
    
  
  
    <label class="md-nav__title" for="__toc">Table of contents</label>
    <ul class="md-nav__list" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#preparation-and-requirements" class="md-nav__link">
    Preparation and requirements
  </a>
  
    <nav class="md-nav">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#qtrobot-setup" class="md-nav__link">
    QTrobot setup
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#your-machine-setup-eg-qtpc" class="md-nav__link">
    Your machine setup (e.g. QTPC)
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#clone-and-build-the-motors_moveit" class="md-nav__link">
    clone and build the motors_moveit
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#how-to-run-the-examples" class="md-nav__link">
    How to run the examples
  </a>
  
    <nav class="md-nav">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#drawing-rectangle" class="md-nav__link">
    Drawing rectangle
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#drawing-spiral" class="md-nav__link">
    Drawing spiral
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
      
      
      
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          <div class="md-content">
            <article class="md-content__inner md-typeset">
              
                
                
                <h1 id="controlling-qtrobot-arms-using-moveit">Controlling QTrobot arms using MoveIt</h1>
<div class="admonition question">
<p>Get the full code in our <a href="https://github.com/luxai-qtrobot/tutorials/tree/master/examples">github tutorial repository.</a></p>
</div>
<p>This advanced example demonstrates how to use ROS MoveIT to control QTrobot arms. The example draw some shapes (i,e. rectangle and spirals) on the XY plane in robot frame.</p>
<p><img alt="QTrobot MoveIt" src="../../img/qt_moveit.png" /></p>
<h2 id="preparation-and-requirements">Preparation and requirements</h2>
<p>Before running the example, please ensure that following setups of your QTrobot and the machine which you are running the example.</p>
<h3 id="qtrobot-setup">QTrobot setup</h3>
<p>By default QTrobot motors interface runs in <em>'normal'</em> mode. in normal mode, the motors control loop and joints state publisher run in low frequency (2-5hz). More importantly the joint position values are in <em>degree</em>. To be able to use MoveIt with QTrobot, you need to configure it to run in <em>'advanced'</em> mode:
- joints position value is in <em>radian</em>
- motors main controller loop and joints state publisher runs in 30hz.
- required interfaces and controller such as <code class="codehilite"><span class="err">robot_state_publisher</span></code> and <code class="codehilite"><span class="err">JointTrajectoryController</span></code> are available</p>
<p><strong>Update ros-kinetic-qt-motor package if necessary:</strong></p>
<p>First check and update (if necessary) the <code class="codehilite"><span class="err">ros-kinetic-qt-motor</span></code> package on the QTrobot head machine (QTRP). ssh to the QTRP (e.g. via QTPC or your desktop) and
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: apt list ros-kinetic-qt-motor</span>
<span class="err">ros-kinetic-qt-motor/now 1.2.0-0xenial armhf [installed,local]</span>
</code></pre></div>
if the version of <code class="codehilite"><span class="err">ros-kinetic-qt-motor</span></code> is older then <code class="codehilite"><span class="err">1.2.0</span></code>, you NEED to update it:</p>
<p>make a copy of your current QTrobot configuration (<code class="codehilite"><span class="err">qtrobot-hardware.yaml</span></code>). You need this file to put it back after updating the package:
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: cp /opt/ros/kinetic/share/qt_motor/config/qtrobot-hardware.yaml ~/</span>
</code></pre></div>
install the latest version of <code class="codehilite"><span class="err">ros-kinetic-qt-motor</span></code>. in my case it is <code class="codehilite"><span class="err">1.2.0-0</span></code>:
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: cd ~/robot/packages/dep</span>
<span class="err">qtrobot@QTXXX: git pull</span>
<span class="err">qtrobot@QTXXX: sudo apt remove ros-kinetic-qt-motor</span>
<span class="err">qtrobot@QTXXX: sudo dpkg -i ros-kinetic-qt-motor_1.2.0-0xenial_armhf.deb</span>
</code></pre></div>
put back your QTrobot configuration (<code class="codehilite"><span class="err">qtrobot-hardware.yaml</span></code>):
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: sudo cp ~/qtrobot-hardware.yaml /opt/ros/kinetic/share/qt_motor/config/</span>
</code></pre></div></p>
<p><strong>Change motor launcher autostart script to run in advanced mode:</strong>
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: nano ~/robot/autostart/start_qt_motor.sh</span>
</code></pre></div>
and change the corresponding line to look like the following and save and exit:
<div class="codehilite"><pre><span></span><code><span class="err">roslaunch qt_motor qt_motor_advanced.launch</span>
</code></pre></div></p>
<p>Reboot the robot to run the advance motor interface.</p>
<p><strong>Check the advanced mode setup:</strong>
After rebooting the reboot, you can check (from QTPC, QTRP or your machine) if the motor interface is running in the advanced mode:</p>
<p>joint state publisher frequency:
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: rostopic hz /qt_robot/joints/state</span>
<span class="err">average rate: 30.041</span>
<span class="err">    min: 0.029s max: 0.047s std dev: 0.00391s window: 29</span>
</code></pre></div></p>
<p>joints value should be in radian:
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: rostopic echo /qt_robot/joints/state</span>
<span class="c">position: [0.015707962851830046, 0.0, -0.6073745663782212, 1.569051024174513, -0.9896016991965904, -0.5689773095185405, -0.3455751785790718, -0.8360127383368947]</span>
</code></pre></div></p>
<p>trajectory controller is running:
<div class="codehilite"><pre><span></span><code><span class="err">qtrobot@QTXXX: rostopic type  /qt_robot/left_arm_controller/follow_joint_trajectory/goal</span>
<span class="err">control_msgs/FollowJointTrajectoryActionGoal</span>
</code></pre></div></p>
<h3 id="your-machine-setup-eg-qtpc">Your machine setup (e.g. QTPC)</h3>
<p>After checking and updating the QTrobot setup, you can install the iKfast solver plugin for MoveIt on the machine which you plan to run the example:</p>
<p>clone the QTrobot open software repository:
<div class="codehilite"><pre><span></span><code><span class="err">cd ~/</span>
<span class="err">git clone https://github.com/luxai-qtrobot/software.git</span>
</code></pre></div>
build the plugins:
<div class="codehilite"><pre><span></span><code><span class="err">cd ~/catkin_ws</span>
<span class="err">ln -s ~/software/qtrobot_ikfast_right_arm_plugin/ ./</span>
<span class="err">ln -s ~/software/qtrobot_ikfast_right_left_plugin/ ./</span>
<span class="err">cd ../</span>
<span class="err">catkin_make</span>
</code></pre></div></p>
<h2 id="clone-and-build-the-motors_moveit">clone and build the motors_moveit</h2>
<p>Assuming that you have cloned the <code class="codehilite"><span class="err">tutorial</span></code> repository somewhere on your home folder (e.g. <code class="codehilite"><span class="err">~/tutorials</span></code>):</p>
<p><div class="codehilite"><pre><span></span><code><span class="err">cd ~/catkin_ws</span>
<span class="err">ln -s ~/tutorials/examples/motors_moveit ./</span>
<span class="err">cd ../</span>
<span class="err">catkin_make</span>
</code></pre></div>
or copy the <code class="codehilite"><span class="err">motors_moveit</span></code> to your catkin_ws.  </p>
<h2 id="how-to-run-the-examples">How to run the examples</h2>
<p>Launch <code class="codehilite"><span class="err">moveit_qtrobot.launch</span></code> to start move_group planner and rviz:</p>
<div class="codehilite"><pre><span></span><code><span class="err">roslaunch motors_moveit moveit_qtrobot.launch</span>
</code></pre></div>

<p>wait until rviz shows up, then run one of the following demos:</p>
<h3 id="drawing-rectangle">Drawing rectangle</h3>
<div class="codehilite"><pre><span></span><code><span class="err">rosrun motors_moveit draw_rectangle.py joint_states:=/qt_robot/joints/state</span>
</code></pre></div>

<h3 id="drawing-spiral">Drawing spiral</h3>
<div class="codehilite"><pre><span></span><code><span class="err">rosrun motors_moveit draw_spiral.py joint_states:=/qt_robot/joints/state</span>
</code></pre></div>
                
                  
                
                
                  
                  <hr>
                  <div class="md-source-date">
                    <small>
                      
                        Last update: April 22, 2020
                      
                    </small>
                  </div>
                
              
              
                


              
            </article>
          </div>
        </div>
      </main>
      
        <!--
  Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to
  deal in the Software without restriction, including without limitation the
  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  sell copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  IN THE SOFTWARE.
-->



<!-- Application footer -->
<footer id="footer" class="md-footer">

  <!-- Link to previous and/or next page -->
  

  <!-- Further information -->
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <!-- Copyright and theme information -->
      <div class="md-footer-copyright">
        
          <div class="md-footer-copyright__highlight">
            &copy; Copyright &copy; 2020 LuxAI S.A.
          </div>
        
      </div>

      <!-- Social links -->
      
  <div class="md-footer-social">
    <link rel="stylesheet" href="../../assets/fonts/font-awesome.css">
    
      <a href="https://github.com/luxai-qtrobot" target="_blank" rel="noopener" title="github" class="md-footer-social__link fa fa-github"></a>
    
      <a href="https://twitter.com/qtrobot" target="_blank" rel="noopener" title="twitter" class="md-footer-social__link fa fa-twitter"></a>
    
      <a href="https://www.linkedin.com/company/luxai/" target="_blank" rel="noopener" title="linkedin" class="md-footer-social__link fa fa-linkedin"></a>
    
      <a href="https://www.facebook.com/luxAI/" target="_blank" rel="noopener" title="facebook" class="md-footer-social__link fa fa-facebook"></a>
    
      <a href="https://www.youtube.com/channel/UCAY0H0HaqQL1GE7lO_iSpbg" target="_blank" rel="noopener" title="youtube" class="md-footer-social__link fa fa-youtube"></a>
    
  </div>

    </div>
  </div>
</footer>
      
    </div>
    
      <script src="../../assets/javascripts/application.c33a9706.js"></script>
      
      <script>app.initialize({version:"1.1",url:{base:"../.."}})</script>
      
        <script src="../../javascripts/extra.js"></script>
      
    
  </body>
</html>